module lab2C
{
	uses interface Boot;

	uses interface AlohaSend;
	uses interface AlohaReceive;
	uses interface AlohaState;
	uses interface Packet;
	uses interface Timer<TMilli> as myTimer;
	uses interface Leds;
}
implementation {
	uint8_t g_channel = 7; 
	uint8_t counter = 0; 
	
	message_t ball;

	uint8_t g_state = STATE_READY;

	event void Boot.booted() 
	{
		call AlohaState.start();
	}

	event void myTimer.fired() 
	{
		myMsg_t * testMsg = NULL;
		testMsg = (myMsg_t *)(call Packet.getPayload(&ball,sizeof(myMsg_t)));
		counter++;
		testMsg->myData = counter;
		call AlohaSend.send(&ball, 3);

		call Leds.led1Toggle();


	}

	/**************************************************************************
	 * 
	 * 			AlohaSend interface
	 * 
	 * 
	 **************************************************************************/
	//command error_t cancel(message_t* msg);
	//command error_t send(message_t* msg, am_addr_t destination); 

	event void AlohaSend.sendDone(error_t error) {

		call myTimer.startOneShot(1000);

	}

	/***************************************************************************
	 * 
	 * 			AlohaReceive interface
	 * 
	 * 
	 **************************************************************************/
	//command error_t receive(); 

	event message_t * AlohaReceive.receiveDone(message_t * txMsg, error_t error) 
	{



	}

	/***************************************************************************
	 * 
	 * 			AlohaState interface
	 * 
	 * 
	 **************************************************************************/


	event void AlohaState.startDone(error_t error) {

		call myTimer.startOneShot(1000);
	}

	event void AlohaState.stopDone(error_t error) 
	{
	}

	event void AlohaState.setChannelDone(error_t error) {

	}

}
